<%@ page import="model.UserService" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: sy189
  Date: 2022/5/11
  Time: 10:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
<%--    bootstrap--%>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style>
        #formipt{
            width: 500px;
            float: left;
        }
        .ipt{
            float: left;
            width: 450px;
        }
        .btnsub{
            float: left;

        }
    </style>
</head>
<%
    request.setCharacterEncoding("UTF-8");
    String username = request.getParameter("username");
    UserService us = new UserService();
    List<Map<String,String>> users =  us.getUsers(username);

%>
<body>
<div align="center">
    <div id="formipt">
        <form action="" >
            <input type="text" name="username" class="form-control col-2" class="ipt" value="" placeholder="请输入用户名"/>
            <input type="submit" class="btnsub btn" value="搜索"/>
        </form>
    </div>
<%--    表格--%>
    <table class="table">
        <thead>
        <tr>
            <th scope="col">#</th>
            <th scope="col">用户名</th>
            <th scope="col">密码</th>
            <th scope="col">角色</th>
            <th scope="col">电话</th>
            <th scope="col">地址</th>
            <th scope="col">操作</th>
            <th scope="col">修改</th>

        </tr>
        </thead>
        <tbody>
        <%
            int num = 0;
            for(Map<String,String> u : users){
                num++;
//                System.out.println(num);
        %>
        <tr>
            <th scope="row"><%=num%></th><input type="hidden" name="id" value="<%=u.get("id")%>">
            <td><%=u.get("username")%></td>
            <td><%=u.get("password")%></td>
            <td><%=u.get("ident").equals("1")?"管理员":"普通用户"%></td>
            <td><%=u.get("telephone")%></td>
            <td><%=u.get("address")%></td>
<%--            <td><a href="javascript:;" onclick="delbtn()" class="btn btn-danger">删除</a> </td>--%>
            <td><a href="../deluser?ID=<%=u.get("id")%>" onclick="return confirm('确定要删除吗？')" class="btn btn-danger">删除</a> </td>
            <td><a href="updUser.jsp?ID=<%=u.get("id")%>">修改</a></td>
        </tr>
        <%
            }
        %>

        </tbody>
    </table>
</div>
<script>

</script>
</body>
</html>
